from django.db import models

# Create your models here.
class hostGroup(models.Model):
    hostGroupName = models.CharField(max_length=20,unique=True)
    hostsNum = models.IntegerField(default=0)
    hostGroupDes = models.CharField(max_length=100,null=True,blank=True)
    ctime = models.DateTimeField(auto_now_add=True)
    uptime = models.DateTimeField(auto_now=True)
    def __str__(self):
        return self.hostGroupName
    class Meta:
        verbose_name = '主机组'
        verbose_name_plural = '主机组'
class hostMangerUser(models.Model):
    managerName = models.CharField(max_length=20)
    managerPasswd = models.CharField(max_length=50)
class hostInfo(models.Model):
    hostName = models.CharField(max_length=20,unique=True)
    hostPublicIP = models.CharField(max_length=40)
    hostSSHPort = models.IntegerField(default=22,blank=True)
    host_machine_room=(
        (0,'azure'),
        (1,'aliyun'),
    )
    hostLocation = models.IntegerField(choices=host_machine_room,default=0)
    hostSeviceList= models.CharField(max_length=2000,null=True,blank=True)
    hostUpdate = models.IntegerField(default=0) # 是否更新
    hostgroup = models.ForeignKey(hostGroup)
    manageruser = models.ForeignKey(hostMangerUser)
    ctime = models.DateTimeField(auto_now_add=True)
    uptime = models.DateTimeField(auto_now=True)
    def __str__(self):
        return self.hostName
    class Meta:
        verbose_name = '主机信息'
        verbose_name_plural = '主机信息'
class hostDetail(models.Model):
    hostinfo = models.OneToOneField(hostInfo)
    hostPrivateIP = models.CharField(max_length=40, null=True)
    hostDisk = models.CharField(max_length=20,null=True)
    hostCPU = models.CharField(max_length=20,null=True)
    hostMem= models.CharField(max_length=20,null=True)

